import requests
from bs4 import BeautifulSoup
import re
import urllib
import time
headers = {'user_agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36','host':'bj.fang.anjuke.com'}
url = "https://bj.fang.anjuke.com/loupan/all/p1/"
print url
try:
 r = requests.get(url,headers,timeout=10) 
except urllib.URLError,e:
 print e.reason 
else:
 print("status:",r.status_code)
 html = r.text
title_name = re.findall('<span class="items-name">(.*?)</span>',html)
prices = re.findall('<p class="price">(.*?)<span>(.*?)</span>(.*?)</p>',html)
price_list = []
for price in prices:
 price_list.append(price[0]+price[1]+price[2])
for j in range(0,len(price_list)):
 print title_name[j]+":"+price_list[j]


